<?php

class Admin_Model_DbTable_Pointbr extends Zend_Db_Table
{
    protected $_name = 'pointbr';
    /**
		Recupererle point de la muraille par son id
     */
    public function getPointbr($idpointbr) {
        $idpointbr = (int)$idpointbr;
        $row = $this->fetchRow('idpointbr = ' . $idpointbr);
        if (!$row) {
            throw new Exception("Count not find row $idpointbr");
        }
        return $row->toArray();    
    }
    
    public function addPointbr($latitude, $longitude, $idpointbr_pred) {
        $data = array(
            'latitude' => $latitude,
            'longitude' => $longitude,
            'idpointbr_pred' => $idpointbr_pred,
        );
        $this->insert($data);
    }
    
    public function updatePointbr($idpointbr, $latitude, $longitude, $idpointbr_pred) {
         $data = array(
            'latitude' => $latitude,
            'longitude' => $longitude,
            'idpointbr_pred' => $idpointbr_pred,
        );
        $this->update($data, 'idpointbr = '. (int)$idpointbr);
    }
    
    
	function deletePointbr($idpointbr) {
		$this->delete ( 'idpointbr =' . ( int ) $idpointbr );
	}
    /**
     * 
     * @return  
     */
    public function getAllPointbr() {    
        $all = $this->fetchAll();
        $pointbrs = array();
        $pointbrs['total'] = count($all->toArray());
        $pointbrs['rows'] = $all->toArray();
        return $pointbrs ;
    }   

}
